package com.briup.sms.service.impl;

import com.briup.sms.dao.CategoryMapper;
import com.briup.sms.dao.OrderMapper;
import com.briup.sms.dao.ShopMapper;
import com.briup.sms.dao.UserMapper;
import com.briup.sms.entity.Category;
import com.briup.sms.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class IndexServiceImpl implements IndexService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    CategoryMapper categoryMapper;
    @Autowired
    ShopMapper shopMapper;
    @Autowired
    OrderMapper orderMapper;

    @Override
    public Map<String, Integer> dashboard() {
        HashMap<String, Integer> map = new HashMap<>();
        Integer userCount = userMapper.count();
        Integer shopCount = shopMapper.count();
        Integer categoryCount = categoryMapper.countSecondCategory();
        Integer orderCount = orderMapper.count();
        map.put("categoryNum",categoryCount);
        map.put("userNum",userCount);
        map.put("shopNum",shopCount);
        map.put("orderNum",orderCount);
        return map;
    }
}
